package com.commons;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

public class PageInfo {
/**
 * 该类主要存放分页相关的信息
 */
	int currentPage=1;//当前页号
	int pageCount;//总页数
	int pageSize=5;//每页的记录数
	int recordCount;//总记录数
	String action;//URL
	List list=new ArrayList();//当前页的数据
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public int getPageCount() {
		return this.recordCount%this.pageSize==0?this.recordCount/this.pageSize:this.recordCount/this.pageSize+1;
	}
	
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getRecordCount() {
		return recordCount;
	}
	public void setRecordCount(int recordCount) {
		this.recordCount = recordCount;
	}
	public List getList() {
		return list;
	}
	public void setList(List list) {
		this.list = list;
	}
	
	public String getAction() {
		return action;
	}
	public void setAction(String action) {
		this.action = action;
	}
	public PageInfo(HttpServletRequest request) {
		//获得请求URL
		String uri=request.getRequestURI();
		this.setAction(uri);
		String page=request.getParameter("currentPage");
		if(page!=null) {
			this.currentPage=Integer.valueOf(page);
		}
		request.setAttribute("pageInfo", this);
	}
	
	
}
